import Vue from "vue";
import VueRouter from "vue-router";
// import menu from "@/plugins/menu";
import store from "../store";
// console.log("store: ", store);
Vue.use(VueRouter);

const routes = [
  {
    path: "/Login",
    name: "Login",
    component: () => import("@/views/Login"),
    meta: { title: "登录" },
  },
  {
    path: "/",
    name: "Main",
    redirect: "/Home",
    component: () => import("@/views/Main"),
    children: store.state.menu,
  },
];
// console.log("store.state.menu: ", store.state.menu);

const router = new VueRouter({
  routes,
});

export default router;

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
